#!usr/bin/env python
# -*- coding: utf-8 -*-
import requests


def get_proxies_tunnel(https=None):
    # 隧道域名:端口号
    tunnel = "s609.kdltps.com:15818"
    # 用户名密码方式
    username = "t17988120381419"
    password = "llq22hml"
    proxies = {
        "http": "http://%(user)s:%(pwd)s@%(proxy)s/" % {"user": username, "pwd": password, "proxy": tunnel},
    }
    if https is not False:
        proxies.update(
            https="http://%(user)s:%(pwd)s@%(proxy)s/" % {"user": username, "pwd": password, "proxy": tunnel})
    return proxies

def get_proxies_tunnel_qingting(https=None):
    # 隧道域名:端口号
    tunnel = "dyn.horocn.com:50000"
    # 用户名密码方式
    username = "UASS1773821605798950"
    password = "DSC5HXF6ncSSjj1p"
    proxies = {
        "http": "http://%(user)s:%(pwd)s@%(proxy)s/" % {"user": username, "pwd": password, "proxy": tunnel},
    }
    if https is not False:
        proxies.update(
            https="http://%(user)s:%(pwd)s@%(proxy)s/" % {"user": username, "pwd": password, "proxy": tunnel})
    return proxies


def get_proxies():
    # 提取代理API接口，获取1个代理IP
    api_url = "https://dps.kdlapi.com/api/getdps/?secret_id=oh8e4oc1xag5vpu3rf5h&num=1&signature=o4gnu5p2ld2gusng8ml6grgc64&pt=1&sep=1"

    # 获取API接口返回的代理IP
    proxy_ip = requests.get(api_url).text.encode('utf-8')

    # 用户名密码认证(私密代理/独享代理)
    username = "chuanxuelove"
    password = "ii3uwuf2"
    proxies = {
        "http": "http://%(user)s:%(pwd)s@%(proxy)s/" % {"user": username, "pwd": password, "proxy": proxy_ip},
        "https": "http://%(user)s:%(pwd)s@%(proxy)s/" % {"user": username, "pwd": password, "proxy": proxy_ip}
    }
    return proxies
